<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>登陆</title>
    <link href="__PUBLIC__/css/Sign%20in.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="__PUBLIC__/js/jquery-1.12.1.js"></script>
</head>
<body>
<div class="All">
    <div class="content">
        <div class="menu">
            <div class="title">Sign Up</div>
            <div class="user">
                <div class="username">
                    <img src="__PUBLIC__/images/user.png">
                </div>
                <div class="null">
                    <input type="text">
                </div>
            </div>
            <div class="pass">
                <div class="password">
                    <img src="__PUBLIC__/images/lock.png">
                </div>
                <div class="nulll">
                    <input type="password">
                </div>
            </div>
            <div class="Button">
                <div class="btn1">
                    登陆
                </div>
                <div class="btn2">
                    注册
                </div>
            </div>
        </div>
        <div class="other">
            <div class="else">其他方式登陆：</div>
            <div class="elses">
                <img src="__PUBLIC__/images/qq.png">
                <img src="__PUBLIC__/images/wechat.png">
                <img class="weibo" src="__PUBLIC__/images/weibo.png">
            </div>
        </div>
    </div>
</div>
</body>
</html>
<script>
    $(function(){
        $(".btn1").click(function(){
            $.post("{:U('login2')}",
                    {
                        name:$(".null input").val(),
                        password:$(".nulll input").val()
                    },
                    function(data,status){
                        if(data=="right"){
                            var href="{:U('index')}";
                            window.location.href=href;
                        }else{
                           alert("登录失败，用户名或秘密错误");
                        }
                    });
        });
        $(".btn2").click(function(){
            window.location.href="{:U(register)}";
        });
    });

    function setCookie(username,value)
    {
        var Days = 30;
        var exp=new Date();
        exp.setTime(exp.getTime() + Days*24*60*60*1000);
        document.cookie = username+ "="+ escape (value) + ";expires=" + exp.toGMTString();
    }
    //读取cookies
    function getCookie(username)
    {
        var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
        if(arr=document.cookie.match(reg)) return unescape(arr[2]);
        else return null;
    }
    //删除cookies
    function delCookie(username)
    {
        var exp = new Date();
        exp.setTime(exp.getTime() - 1);
        var cval=getCookie(username);
        if(cval!=null) document.cookie= username + "="+cval+";expires="+exp.toGMTString();
    }
    //使用示例
    setCookie("username","ada ");
    //    alert(getCookie("username"));
</script>